#include <QCoreApplication>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    int x,y;
    cin>>x;
    y=3*(x*x*x*x*x*x)-6*(x*x)-7;
    cout<<y;
    return a.exec();
}
